package com.wel.myBook.Utils;

import java.net.URL;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

/**
 * html页面解析工具
 * @author wel.xiao
 * 2013-4-7
 */
public class HtmlParseUtils {

	/**
	 * 
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
		Document doc = Jsoup.parse(new URL("http://www.baikv.com/xiaoshuo/2.html"), 1000);
		Element element = doc.getElementById("centerl");
		String[] bookPath = getBookPath(element);
		System.out.println("书分类名："+bookPath[1]);
		System.out.println("书名："+bookPath[2]);
	}
	
	/**
	 * 
	 * @param element
	 * @return
	 */
	public static String[] getBookPath(Element element) {
		Elements elements = element.getElementsByClass("navigation");
		Element el = elements.first();
		String current = el.text();
		String[] bookPath = current.split(">");
		return bookPath;
	}
	
}
